//package com.ykt.controller;
//
//import java.util.ArrayList;
//import java.util.Date;
//import java.util.List;
//import java.util.Random;
//
//import com.jfinal.ext.route.ControllerBind;
//import com.jfinal.plugin.activerecord.Db;
//import com.jfinal.plugin.activerecord.Record;
//import com.ykt.model.GoodsUnit;
//import com.ykt.model.Shop;
//import com.ykt.model.ShopGoods;
//import com.ykt.vo.page.TreeNode;
//
//@ControllerBind(controllerKey="/shopGoods")
//public class ShopGoodsController extends BaseController<ShopGoods>{
//	public ShopGoodsController(){
//		super(ShopGoods.class);
//	}
//
//	/**
//	 * 下拉列表多选
//	 */
//	public void combotree() {
//
//		String sql="select id,name from goods_unit";
//
//		List<Record> dataList = Db.find(sql);
//		List<TreeNode> list = new ArrayList<TreeNode>();
//		for(Record r : dataList ){
//			TreeNode rootNode = new TreeNode();
//			rootNode.setId(r.getInt("id"));
//			rootNode.setText(r.getStr("name"));
//			rootNode.setIconCls("icon-home");
//			rootNode.setCanChk(false);
//			list.add(rootNode);
//		}
//		this.renderJson(list);
//	}
//
//	public void save() {
//		String goodsId = this.getPara("goods_id");
//		String shop_id = this.getPara("shop_id");
//
//		String[] unitsId = this.getParaValues("unitIds");
//
//		Shop shop = Shop.dao.findFirst("SELECT * FROM shop s WHERE s.id = " + shop_id);
//
//		String[] goods_id = goodsId.split(",");
//		for (String g : goods_id) {
//			String sql = "SELECT * FROM shop_goods s WHERE s.shop_id = " + shop_id + " AND s.goods_id = " + g;
//			ShopGoods shopGoods = null;
//			shopGoods = ShopGoods.dao.findFirst(sql);
//			for(String unitId : unitsId){
//				GoodsUnit gu = GoodsUnit.dao.findById(Integer.valueOf(unitId));
//				if (shopGoods == null) {
//					ShopGoods goods = new ShopGoods();
//					goods.set("goods_id", g);
//					goods.set("shop_id", shop_id);
//					goods.set("market_id", shop.get("market_id"));
//					goods.set("price", 0);
//					goods.set("created_time", new Date());
//					//goods.set("updated_time", new Date());
//
//					goods.set("unit", gu.get("name"));
//
//					goods.save();
//				}
//			}
//		}
//		Integer id = null;
//		String  msg = "保存成功！";
//		rendJson(true, msg, id, new Random().nextLong());
//	}
//}
